import {request} from '../../utils/http'

Page({
  data: {
    info:{
      bank: '',
      bank_user_name: '',
      card_no: '',
      card_type: '',
      card_type_cn: '',
      is_can_unbind:'',
      life_check: 0,
      mobile: '',
      status: '',
      status_cn:''
    },
    userInfo:{

    }
  },
  onLoad() {
    this.getBankCards()
  },
  onShow() {
    my.getStorage({
      key: 'userInfo',
      success: (res) => {
        console.log(res)
        if (res.data) {
          this.setData({
            userInfo: res.data,
          })
        }
      }
    });
  },
  getBankCards(){
    request('/member/get_bank_cards','get').then(res => {
      if (res.code == 200) {
        this.setData({
          info:res.data
        })
      }
    })
  },
  unbindCard(){
    let self = this
    my.confirm({
      title:'解除授权提醒',
      content:'确认是否解除该银行卡代扣授权',
      confirmButtonText:'确定',
      cancelButtonText:'取消',
      success(result){
        if (result.confirm) {
          request('/member/unbind_card', 'post').then(res => {
            if (res.code == 200) {
              self.getBankCards()
            } else {
              
            }
          })
        }
      }
    })
    
  }
});
